05. Where else to use Dependency Injection?

L5 P3 A01 Where Else To Use Dependency Injection

You're going to set up the TasksViewModel for testing. Answer the following questions.

Given you are writing tests for the TasksViewModel, what class should you make a test double for?

SOLUTION: DefaultTasksRepository

What type of test double should we make?

SOLUTION: Fake

What type of dependency injection should we use here?

SOLUTION: Constructor Injection

Which class should we change the constructor of to use constructor dependency injection?

SOLUTION: ViewModel

What are the dependencies you will inject?

SOLUTION: Repository

This is review from the previous course. What class must you implement to change the constructor of a ViewModel?

SOLUTION: ViewModelProvider.Factory